import * as types from './types'
export function count(state,action){
  // 1. 给state付了一个默认值  2.可以用来修改state中的数据
  state = state || {
    count:1000,
    name:666,
    age:666
  }
  switch (action.type) {
    case types.ADD:
      return {
        ...state,
        count:state.count + action.qqq
      }
    case types.MINUS:
      return {
        ...state,
        count:state.count - action.qqq
      }
  
    default:
      return {
        ...state
      }
  }
}
export function color(state,action){
  if(action.type == types.CHNAGE_COLOR){
    return {
      ...state,
      color:action.col || 'red'
    }
  }else{
    return {
      color:action.col || 'red'
    }
  }
}